# Maintainer: Tao Zuhong <taozuhong@hotmail.com>

_realname=nanoarrow
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.6.0
pkgrel=1
pkgdesc="Helpers for Arrow C Data & Arrow C Stream interfaces (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://arrow.apache.org/nanoarrow/'
license=('spdx:Apache-2.0')
makedepends=("${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-pkgconf"
             "${MINGW_PACKAGE_PREFIX}-cc")
source=("https://github.com/apache/arrow-nanoarrow/releases/download/apache-arrow-nanoarrow-${pkgver}/apache-arrow-nanoarrow-${pkgver}.tar.gz"{,.asc})
sha256sums=('e4a02ac51002ad1875bf09317e70adb959005fad52b240ff59f73b970fa485d1'
            'SKIP')
validpgpkeys=(
  'AF6AADA4C9835B75973FF5DA275C532289DD0F4A' # Raúl Cumplido Domínguez (CODE SIGNING KEY) <raulcd@apache.org>
  '08D3564B7C6A9CAFBFF6A66791D18FCF079F8007' # Kouhei Sutou <kou@cozmixng.org>
)

build() {
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    meson setup \
      --prefix="${MINGW_PREFIX}" \
      --wrap-mode=nodownload \
      --auto-features=enabled \
      --buildtype=plain \
      "build-${MSYSTEM}" \
      "apache-arrow-${_realname}-${pkgver}"

  meson compile -C "build-${MSYSTEM}"
}

package() {
  meson install -C "build-${MSYSTEM}" --destdir "${pkgdir}"
  install -Dm644 "${srcdir}/apache-arrow-${_realname}-${pkgver}/LICENSE.txt" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE.txt"
}
